﻿using BoldBrick.OneIntranet.HR.DataObjects;
using Microsoft.SharePoint;
using BoldBrick.SharePoint.CommonControls.Extensions;

namespace BoldBrick.OneIntranet.HR.WebParts.HRWorkflowStatisticsWebPart
{
	public class HRStatisticsItem
	{
		public int WorkflowStepOrder { get; set; }

		public string WorkflowStepName { get; set; }
		
		public int WorkflowStepID { get; set; }

		public int Index { get; set; }

		public int CandidateCount { get; set; }

		public string XValue
		{
			get { return string.Format("{0}. {1}", this.Index + 1, this.WorkflowStepName); }
		}

		public HRStatisticsItem(SPListItem itemWorkflowStep, int index)
		{
			this.WorkflowStepID = itemWorkflowStep.ID;

			this.WorkflowStepName = itemWorkflowStep.Title;
			
			double? order = itemWorkflowStep.GetValue<double>(SiteColumns.WorkflowStepOrderColumn.InternalName);
			if (order.HasValue)
			{
				this.WorkflowStepOrder = (int) order;
			}

			this.Index = index;
		}
	}
}
